<template>
  <div class="app-container">

    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">

      <el-row :gutter="20">
        <el-col :span="24" align="right">
          <el-form-item label="来料批次" prop="cpCode">
            <el-input
              v-model="queryParams.cpCode"
              placeholder="请输入来料批次"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-col>
      </el-row>

    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['warehouse:llrk:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="FhslQuantityShippedList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" width="55">
        <template slot-scope="scope">
          <span>{{ scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="客户名称" align="center" prop="fhjlShippingRecordForm.ksMerchants.merchantsName" width="180" />
      <el-table-column label="产品编码" align="center" prop="fhjlShippingRecordForm.cpProduct.cpCode" />
      <el-table-column label="产品名称" align="center" prop="fhjlShippingRecordForm.cpProduct.cpName" />
      <el-table-column label="产品类型" align="center" prop="fhjlShippingRecordForm.cpProduct.cpLxcode" />
      <el-table-column label="产品型号" align="center" prop="fhjlShippingRecordForm.cpProduct.cpType">
<!--        <template slot-scope="scope">-->
<!--          <dict-tag :options="dict.type.wl_type" :value="scope.row.llrkIncomingMaterialStorage.wldaMaterialFile.wlTypecode"/>-->
<!--        </template>-->
      </el-table-column>
      <el-table-column label="产品分类" align="center" prop="fhjlShippingRecordForm.cpProduct.cpflProductClassification.cpflName" />
      <el-table-column label="产品品牌" align="center" prop="fhjlShippingRecordForm.cpProduct.cpppProductBrand.ppName" />
      <el-table-column label="产品批次号" align="center" prop="cppcCode" />
      <el-table-column label="发货仓库" align="center" prop="ckWarehouse.ckName" />
      <el-table-column label="发货数量" align="center" prop="fhNum" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import {listFhtj} from "@/api/statistical/fhtj";


export default {
  name: "fhtj",
  dicts: ['wl_from', 'is_use', 'wl_type', 'wl_sortcode'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 子表选中数据
      checkedWldaMaterialFile: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 来料入库表格数据
      llrkList: [],
      // 物料档案表格数据
      wldaMaterialFileList: [],
      // 物料统计
      LlslIncomingMaterialsList: [],
      FhslQuantityShippedList: [],
      // 客商档案表格数据
      ksMerchantsList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        cpCode: null
      },
      dateRange:[],
      // 表单参数
      form: {},
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 表单重置
    reset() {
      this.form = {
        llCode: null,
        ksCode: null,
        wlCode: null,
        getTime: null,
        isUse: null,
        isDelete: null,
        wldaMaterialFile: {
          wlName:null,
          wlCode:null
        },
        ksMerchants:{
          ksCode:null,
          merchantsName:null
        }
      };
      this.wldaMaterialFileList = [];
      this.value=null;
      this.resetForm("form");
    },
    /** 查询来料入库列表 */
    getList() {
      this.reset();
      this.loading = true;
      listFhtj(this.queryParams).then(response => {
        this.FhslQuantityShippedList = response.rows;
        console.log(this.FhslQuantityShippedList)
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.llCode)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 复选框选中数据 */
    handleWldaMaterialFileSelectionChange(selection) {
      this.checkedWldaMaterialFile = selection.map(item => item.index)
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('warehouse/llrk/export', {
        ...this.queryParams
      }, `llrk_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
